package org.example.RabbitMq.amqpService.impl;

import org.example.RabbitMq.amqpService.IdGeneratorService;
import org.example.utils.RandomUtil;
import org.example.utils.SnowflakeIdWorker;
import org.example.utils.TimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @Author : zhangbo
 * @data : 2024/7/12
 * @description :
 */
@Service
public class IdGeneratorServiceImpl implements IdGeneratorService {
    @Autowired
    private SnowflakeIdWorker snowflakeIdWorker;

    @Override
    public String getVipOrderNumber() {
        return TimeUtil.getNewTime() + RandomUtil.getRandomNumbers(6);
    }

    @Override
    public String getModelPrimaryKey() {
        return UUID.randomUUID().toString().replace("-", "");
    }

    @Override
    public Number getModelPrimaryKeyNumber() {
        return snowflakeIdWorker.nextId();
    }
}
